// JavaScript Document
;
(function($){
	$.extend({
		//������
		tcMask:function(options){
			var defaults={
				zz:"<div class='mask'></div>",
				url:"",
				params:"",
				tc:"<div class='tanchu'></div>"
			};
			var options=$.extend(defaults,options);
			var iDocuH=$(document).height();
			var iDocuW=$(document).width();
			var isIE6=$.browser.msie&&$.browser.version==6.0;

			if($(".mask").size()>=1){
				$(".mask").show();
			}else{
				$("body").append(options.zz);
				$(".mask").css({"width":iDocuW+"px","height":iDocuH+"px","display":"block"});
			}
			if($(".tanchu").size()>=1){
				$(".tanchu").remove();
			}else{
				$("body").append(options.tc);
			}
			var iTcW;
			var iTcH;
			var iWinW;
			var iWinH;
			var tcTop;
			var tcLeft;
			$(".tanchu").load(options.url,options.params,function(){
				 iTcW=$(".tanchu").width();
				 iTcH=$(".tanchu").height();
				 iWinW=$(window).width();
				 iWinH=$(window).height();
				 tcTop=(iWinH-iTcH)/2;
				 tcLeft=(iWinW-iTcW)/2;
				 if(isIE6){
						$(".tanchu").css({"display":"block","position":"absolute","left":tcLeft+"px","top":tcTop+"px"});
						$(window).scroll(function(){
							$(".tanchu").css({"display":"block","position":"absolute","left":tcLeft+"px","top":tcTop+$(window).scrollTop()+"px"});
						});
					}else{
						$(".tanchu").css({"display":"block","position":"fixed","left":tcLeft+"px","top":tcTop+"px"});	
					}
			});
			
			$(".tc_wrap .btn_close").live("click",function(){
				$(".tanchu").hide().remove();
				$(".mask").hide();							
			});
		},
		
		//lunbo
		lbShow:function(options){
			var defaults={
				picUL:"picUL",//�ֲ�ͼƬul-id;
				numsUL:"numsUL",//���ul-id;
				styles:"click", //���״̬
				time:4000  //ʱ��
			}
			var options=$.extend(defaults,options);
			var oPicUL=$("#"+options.picUL+" li");
			var oNumsUL=$("#"+options.numsUL+" li");
			var iPicLen=oPicUL.length;
			var index=1;
			var st;
			function lbOperate(indexM){
				oPicUL.eq(indexM).show().addClass("current").siblings().removeClass("current").hide();
				oNumsUL.eq(indexM).addClass("current").siblings().removeClass("current");	
			}
			//��ʼ��
			lbOperate(0);
			function lunbo(){
				if(index==iPicLen){
					index=0;	
				}
				lbOperate(index);
				index++;
				st=setTimeout(lunbo,options.time);
			}
			
			st=setTimeout(lunbo,options.time);
			
			oPicUL.hover(function(){
				clearTimeout(st);						  
			},function(){
				index=$("#"+options.picUL).find(".current").index()+1;
				st=setTimeout(lunbo,options.time);	
			});
			
			if(options.styles=="hover"){
				oNumsUL.hover(function(){
					clearTimeout(st);
					lbOperate($(this).index());
					
				},function(){
					st=setTimeout(lunbo,options.time);
					index=$("#"+options.numsUL).find(".current").index()+1;	
				});
			}else if(options.styles=="click"){
				oNumsUL.hover(function(){
					clearTimeout(st);					   
				},function(){
					st=setTimeout(lunbo,options.time);
					index=$("#"+options.numsUL).find(".current").index()+1;		
				});
				oNumsUL.click(function(){
					lbOperate($(this).index());				  
				});	
			}
			
		}
		
		
		
		
		
	});	  
})(jQuery);